// ==UserScript==
// @name     Unnamed Script 273117
// @version  1
// @grant    none
// @include https://www.h3yun.com/*
// @require Http://libs.baidu.com/jquery/2.0.0/jquery.min.js
// @require https://cdnjs.cloudflare.com/ajax/libs/jstree/3.2.1/jstree.min.js
// @resource jstreestyle https://cdnjs.cloudflare.com/ajax/libs/jstree/3.2.1/themes/default/style.min.css
// ==/UserScript==
import "./scripts/jstree.js"
import sliderControl from "./scripts/sliderControl";
$(function() {
	const TreeData = require('./assets/data.json');

	var HOST = "https://leeeeeonhere.gitee.io/cyml"

	function setupSlider(parentEle) {
		parentEle.find("head").append(
			$("<link>").attr("rel", "stylesheet").attr("type", "text/css").attr("href", HOST + "/assets/default/style.min.css"),
			$("<style>").html("#custom-favorite-slider .custom-favorite-slider-icon-link {background: url('"+ HOST + "/assets/icon-link.png" +"'); background-size: cover !important;}"),
			$("<style>").html("#custom-favorite-slider .custom-favorite-slider-icon-folder {background: url('"+ HOST + "/assets/icon-folder.png" +"'); background-size: cover !important;}")
		);
		/**
		 * @type {SliderControl}
		 */
		let slider2 = sliderControl.getInstance(parentEle, parentEle.find("#app-left-menu"), {HOST});
		slider2.build(TreeData);
		slider2.render();
	}

	var root = $(window.top.document);
	if (!sliderControl.isSliderExists(root)) {
		setupSlider(root);
	}

})
